package leetcode.weekly.week293;

import java.util.ArrayList;
import java.util.List;

// Solution1Test
public class Solution1 {

	public List<String> removeAnagrams(String[] words) {
		List<String> ans = new ArrayList<>();
		int[] last = new int[26];
		for (int i = 0; i < words.length; i++) {
			char[] cur = words[i].toCharArray();
			int[] dics = new int[26];
			for (int j = 0; j < cur.length; j++) {
				int index = cur[j] - 'a';
				dics[index]++;
			}
			if (i != 0) {
				boolean same = true;
				for (int j = 0; j < dics.length; j++) {
					if (last[j] != dics[j]) {
						same = false;
						break;
					}
				}
				if (!same) {
					last = dics;
					ans.add(words[i]);
				}
			} else {
				last = dics;
				ans.add(words[i]);
			}
		}
		return ans;
	}

}
